package com.itheima.File文件;

import java.io.File;

public class 删除多级文件夹版本1 {
    public static void main(String[] args) {
        File file = new File("D:\\黑马视频\\filecopy");
        deleteFile(file);
    }

    private static void deleteFile(File file) {
        if (file.isFile() || (file.isDirectory() && file.listFiles().length == 0)) {
            boolean delete = file.delete();
            System.out.println(file.getName());
            //System.out.println(delete);
            return;
        }
        File[] files = file.listFiles();
        for (File file1 : files) {
            deleteFile(file1);
        }
        System.out.println(file.getName());
        boolean delete = file.delete();
        //System.out.println(delete);
    }
}
